#ifndef YOOHOO_XMPPIM_STANZALISTENER_H
#define YOOHOO_XMPPIM_STANZALISTENER_H

#include "xmppim/export.h"
#include "xmppcore/stanza.h"

namespace yoohoo_xmppim {

class YOOHOO_XMPPIM_EXPORT StanzaListener {
public:
	virtual Stanza::StanzaKind stanzaKind() = 0;
	virtual bool received(Stanza* stanza) = 0;
};

class YOOHOO_XMPPIM_EXPORT PresenceListener : StanzaListener {
public:
	Stanza::StanzaKind stanzaKind() {
		return Stanza::StanzaKindPresence;
	}

	bool received(Stanza* stanza) {
		Presence* presence = dynamic_cast<Presence*>(stanza);
		if (presence != 0) {
			return doReceived(presence);
		}

		return false;
	}

protected:
	virtual bool doReceived(Presence* presence) = 0;
};

class YOOHOO_XMPPIM_EXPORT MessageListener : StanzaListener {
public:
	Stanza::StanzaKind stanzaKind() {
		return Stanza::StanzaKindMessage;
	}

	bool received(Stanza* stanza) {
		Message* message = dynamic_cast<Message*>(stanza);
		if (message != 0) {
			return doReceived(message);
		}

		return false;
	}

protected:
	virtual bool doReceived(Message* message) = 0;
};

class YOOHOO_XMPPIM_EXPORT IqListener : StanzaListener {
public:
	Stanza::StanzaKind stanzaKind() {
		return Stanza::StanzaKindIq;
	}

	bool received(Stanza* stanza) {
		Iq* iq = dynamic_cast<Iq*>(stanza);
		if (iq != 0) {
			return doReceived(iq);
		}

		return false;
	}

protected:
	virtual bool doReceived(Iq* iq) = 0;
};

}

#endif
